<template>
	<view class="wrap">
		<js-lang title="home.title" :showBtn="true"></js-lang>
		<!-- 通知公告 -->
		<view class="noticeWh">
			<view class="noticeWh_title" @click="goNotice('/pages/notice/noticeList')">
				<text>通知公告</text>
				<text class="more">更多</text>
			</view>

			<view
				class="u-line-4"
				v-if="this.noticeList.length > 0"
				@click="goNotice('/pages/notice/noticeDetail?id=' + noticeList[0].id)"
				style="font-size:30rpx;margin-bottom: 20rpx;line-height:50rpx"
			>
				{{ noticeList[0].msgTitle }}
			</view>
			<view class="u-line-4" v-else style="font-size:30rpx;padding-bottom: 20rpx;line-height:50rpx">暂无数据</view>
		</view>

		<!-- 		<view class="box u-p-b-5">
			<view class="u-m-40"><u-button type="primary" @click="to()">经济列表</u-button></view>
		</view> -->

		<u-collapse class="box u-p-b-5" :accordion="false" :arrow="true">
			<view class="item" v-for="(menu, index) in menuList" :key="menu.menuCode">
				<u-collapse-item :open="true">
					<view class="title" slot="title">
						<u-icon :name="menu.menuIcon != '' ? menu.menuIcon : 'home'" :size="40" :style="{ color: menu.menuColor != '' ? menu.menuColor : '#666' }"></u-icon>
						<view class="text" :style="{ color: menu.menuColor != '' ? menu.menuColor : '#666' }">{{ menu.menuName }}</view>
					</view>
					<u-grid class="grid u-m-t-20" :col="3" :border="false">
						<u-grid-item v-for="(child, index2) in menu.childList" :key="child.menuCode" @click="navTo(child.url)">
							<u-icon
								class="grid-icon"
								:name="child.menuIcon != '' ? child.menuIcon : 'order'"
								:size="80"
								:style="{ color: child.menuColor != '' ? child.menuColor : '#666' }"
							></u-icon>
							<view class="grid-text" :style="{ color: child.menuColor != '' ? child.menuColor : '#666' }">{{ child.menuName }}</view>
						</u-grid-item>
					</u-grid>
				</u-collapse-item>
			</view>
		</u-collapse>
	</view>
</template>
<script>
/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
export default {
	data() {
		return {
			imgList: [{ image: '/static/jeesite/banner/1.svg' }, { image: '/static/jeesite/banner/2.svg' }, { image: '/static/jeesite/banner/3.svg' }],

			todoCount: 0,

			menuList: [
				{
					menuCode: 'a-2',
					menuName: '功能列表',
					menuIcon: '',
					menuColor: '#000000',
					url: '',
					childList: [
						{
							menuCode: 'a21',
							menuName: '任务部署',
							menuIcon: '/static/jeesite/home/icon1.png',
							menuColor: '#000000',
							url: '/pages/task/taskInfo/taskInfoList'
						},
						{
							menuCode: 'a22',
							menuName: '部署审核',
							menuIcon: '/static/jeesite/home/icon2.png',
							menuColor: '#000000',
							url: '/pages/task/taskAudit/taskAuditList'
						},
						{
							menuCode: 'a23',
							menuName: '反馈审核',
							menuIcon: '/static/jeesite/home/icon3.png',
							menuColor: '#000000',
							url: '/pages/task/taskAuditFeedback/taskAuditFeedbackList'
						},
						{
							menuCode: 'a24',
							menuName: '任务接收',
							menuIcon: '/static/jeesite/home/icon4.png',
							menuColor: '#000000',
							url: '/pages/task/taskReceive/taskReceiveList'
						},
						{
							menuCode: 'a25',
							menuName: '任务反馈',
							menuIcon: '/static/jeesite/home/icon5.png',
							menuColor: '#000000',
							url: '/pages/task/taskFeedback/taskFeedbackList'
						},

						// {
						// 	menuCode: 'a26',
						// 	menuName: '督办跟踪',
						// 	menuIcon: '/static/jeesite/home/icon6.png',
						// 	menuColor: '#000000',
						// 	url: '/pages/task/supervisionTracking/trackList'
						// },
						{
							menuCode: 'a27',
							menuName: '市领导工作台',
							menuIcon: '/static/jeesite/home/icon7.png',
							menuColor: '#000000',
							url: '/pages/task/ldIndex/ldIndexList'
						},
						// {
						// 	menuCode: 'a28',
						// 	menuName: '专项工作',
						// 	menuIcon: '/static/jeesite/home/icon8.png',
						// 	menuColor: '#000000',
						// 	url: '/pages/task/specialWork/specialWorkList'
						// },
						{
							menuCode: 'a28',
							menuName: '经济指标',
							menuIcon: '/static/jeesite/home/icon8.png',
							menuColor: '#000000',
							url: '/pages/jj/jj'
						},
						{
							menuCode: 'a29',
							menuName: '任务台账',
							menuIcon: '/static/jeesite/home/icon9.png',
							menuColor: '#000000',
							url: '/pages/task/taskAccount/taskAccountList'
						},
						{
							menuCode: 'a30',
							menuName: '整理审核',
							menuIcon: '/static/jeesite/home/icon3.png',
							menuColor: '#000000',
							url: '/pages/task/taskAuditArrange/taskAuditArrangeList'
						},
						// {
						// 	menuCode: 'a31',
						// 	menuName: '经济指标',
						// 	menuIcon: '/static/jeesite/home/icon7.png',
						// 	menuColor: '#000000',
						// 	url: '/pages/jj/jj'
						// }
					]
				}
			],
			noticeList: [],
			roleString: ''
		};
	},
	created() {
		this.getRole();
	},
	onLoad() {
		this.getNoticeApi();
	},
	onShow() {
		// this.refreshCount();
	},
	methods: {
		navTo(url) {
			uni.navigateTo({
				url: url
			});
		},
		to() {
			uni.navigateTo({
				url: '../../jj/jj'
			});
		},
		refreshCount() {
			this.$u.api.task.noCompleteList(this.query).then(res => {
				this.todoCount = res.list.length;
			});
		},
		imgListClick(index) {},
		itemClick(index) {},
		goNotice(url) {
			uni.navigateTo({
				url: url
			});
		},
		getNoticeApi() {
			this.$u.api.notice.list(this.query).then(res => {
				if (res.list.length > 0) {
					this.noticeList = res.list;
				}
			});
		},
		getRole() {
			let param = { userCode: this.vuex_user.userCode };
			let that = this;
			this.$u.api.findListByUserCode(param).then(res => {
				this.roleString = res.data;
				if (this.roleString) {
					this.menuList[0].childList = [];
					//督查单位工作人员-任务部署
					if (res.data.indexOf('OTSDEPLOY') != -1) {
						this.menuList[0].childList.push({
							menuCode: 'a21',
							menuName: '任务部署',
							menuIcon: '/static/jeesite/home/icon1.png',
							menuColor: '#000000',
							url: '/pages/task/taskInfo/taskInfoList'
						});
					}
					//秘书长,督查单位领导-部署审核
					if (res.data.indexOf('SECRETARY_GENERAL') != -1 || res.data.indexOf('SUPLEADER') != -1) {
						this.menuList[0].childList.push({
							menuCode: 'a22',
							menuName: '部署审核',
							menuIcon: '/static/jeesite/home/icon2.png',
							menuColor: '#000000',
							url: '/pages/task/taskAudit/taskAuditList'
						});
					}
					//秘书一科成员,督查单位工作人员-反馈审核
					if (res.data.indexOf('SECRETARY_ONE') != -1 || res.data.indexOf('OTSDEPLOY') != -1) {
						this.menuList[0].childList.push({
							menuCode: 'a23',
							menuName: '反馈审核',
							menuIcon: '/static/jeesite/home/icon3.png',
							menuColor: '#000000',
							url: '/pages/task/taskAuditFeedback/taskAuditFeedbackList'
						});
					}
					//收文员-任务接收
					if (res.data.indexOf('OTSTRANSFER') != -1) {
						this.menuList[0].childList.push({
							menuCode: 'a24',
							menuName: '任务接收',
							menuIcon: '/static/jeesite/home/icon4.png',
							menuColor: '#000000',
							url: '/pages/task/taskReceive/taskReceiveList'
						});
					}
					//督办任务反馈人-任务反馈
					if (res.data.indexOf('OTSLEADERESOLVE') != -1) {
						this.menuList[0].childList.push({
							menuCode: 'a25',
							menuName: '任务反馈',
							menuIcon: '/static/jeesite/home/icon5.png',
							menuColor: '#000000',
							url: '/pages/task/taskFeedback/taskFeedbackList'
						});
					}
					//秘书一科成员,督查单位工作人员-督办跟踪
					// if (res.data.indexOf('SECRETARY_ONE') != -1 || res.data.indexOf('OTSDEPLOY') != -1) {
					// 	this.menuList[0].childList.push({
					// 		menuCode: 'a26',
					// 		menuName: '督办跟踪',
					// 		menuIcon: '/static/jeesite/home/icon6.png',
					// 		menuColor: '#000000',
					// 		url: '/pages/task/supervisionTracking/trackList'
					// 	});
					// }
					//市领导,督查办看领导-市领导工作台
					if (res.data.indexOf('100016') != -1 || res.data.indexOf('100017') != -1) {
						this.menuList[0].childList.push({
							menuCode: 'a27',
							menuName: '市领导工作台',
							menuIcon: '/static/jeesite/home/icon7.png',
							menuColor: '#000000',
							url: '/pages/task/ldIndex/ldIndexList'
						});
					}
					// //市领导,督查办看领导-专项工作
					// if (res.data.indexOf('100016') != -1 || res.data.indexOf('100017') != -1) {
					// 	this.menuList[0].childList.push({
					// 		menuCode: 'a28',
					// 		menuName: '专项工作',
					// 		menuIcon: '/static/jeesite/home/icon8.png',
					// 		menuColor: '#000000',
					// 		url: '/pages/task/specialWork/specialWorkList'
					// 	});
					// }
					//市领导,督查办看领导-专项工作
					if (res.data.indexOf('100016') != -1 || res.data.indexOf('100017') != -1 || res.data.indexOf('data_board') != -1) {
						this.menuList[0].childList.push({
							menuCode: 'a28',
							menuName: '经济指标',
							menuIcon: '/static/jeesite/home/icon8.png',
							menuColor: '#000000',
							url: '/pages/jj/jj'
						});
					}
					//收文员,督办任务反馈人,督查单位工作人员,督查单位领导-任务台账
					if (
						res.data.indexOf('OTSTRANSFER') != -1 ||
						res.data.indexOf('OTSLEADERESOLVE') != -1 ||
						res.data.indexOf('OTSDEPLOY') != -1 ||
						res.data.indexOf('SUPLEADER') != -1
					) {
						this.menuList[0].childList.push({
							menuCode: 'a29',
							menuName: '任务台账',
							menuIcon: '/static/jeesite/home/icon9.png',
							menuColor: '#000000',
							url: '/pages/task/taskAccount/taskAccountList'
						});
					}

					//机关党组成员-整理审核
					if (res.data.indexOf('PARTY_MEMBER') != -1) {
						this.menuList[0].childList.push({
							menuCode: 'a30',
							menuName: '整理审核',
							menuIcon: '/static/jeesite/home/icon3.png',
							menuColor: '#000000',
							url: '/pages/task/taskAuditArrange/taskAuditArrangeList'
						});
					}

					// if (res.data.indexOf('data_board') != -1) {
					// 	this.menuList[0].childList.push({
					// 		menuCode: 'a31',
					// 		menuName: '经济指标',
					// 		menuIcon: '/static/jeesite/home/icon7.png',
					// 		menuColor: '#000000',
					// 		url: '/pages/jj/jj'
					// 	});
					// }
				}
			});
		}
	}
};
</script>
<style lang="scss">
@import 'index.scss';
page {
	background-color: #f8f8f8;
}
.noticeWh {
	margin: 0 20rpx 20rpx;
	padding: 30rpx 30rpx;
	border-radius: 20rpx;
	box-sizing: border-box;
	background-color: #fff;
	font-size: 28rpx;
	.noticeWh_title {
		font-size: 36rpx;
		font-weight: 600;
		padding-bottom: 25rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		.more {
			font-size: 28rpx;
			color: #3e86ff !important;
			font-weight: normal !important;
		}
	}
}
</style>
